package mypazar.pazar;

import jason.environment.grid.Location;
import mypazar.agent.ManagerAgent;
import mypazar.agent.PersonAgent;
import mypazar.agent.SalesmanAgent;
import mypazar.cartago.PazarCartagoEnvironmentStart;
import mypazar.jenamodel.PazarVocabulary;
import tr.edu.ege.seagent.core.platform.SeagentPlatform;

public class PazarMain {

	public static final int PERSON_AGENT_COUNT = 8;

	public static final int SALESMAN_AGENT_COUNT = 4;

	public static final String SEAGENT_MAS_KNOWLEDGE_SAR_PATH = "SEAGENTMASOrg.sar";

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		new PazarMain().executeMarketOrganization();
	}

	private void executeMarketOrganization() throws Exception {
		// create agent environment...
		PazarModel model = new PazarModel();
		// create a view...
		model.setView(new PazarView(model));

		// create cartago environment
		new PazarCartagoEnvironmentStart().startPazarCartagoService();

		// create platform
		SeagentPlatform platform = new SeagentPlatform("mypazar.com",
				SEAGENT_MAS_KNOWLEDGE_SAR_PATH);
		// create initial agent location...
		Location location = new Location(0, 0);

		// create salesman agent
		for (int i = 0; i < SALESMAN_AGENT_COUNT; i++) {
			new SalesmanAgent(PazarVocabulary.SALESMAN_NAME_PREFIX
					+ Integer.toString(i + 1), platform, model, location);

		}

		// create person agent
		for (int i = 0; i < PERSON_AGENT_COUNT; i++) {
			new PersonAgent(PazarVocabulary.PERSON_NAME_PREFIX
					+ Integer.toString(i + 1), platform, model, location);
		}

		// system manager agent
		new ManagerAgent(platform);
	}

}
